﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;

namespace WmsApp.Window
{
    public partial class FormConfirmInOut : DevExpress.XtraEditors.XtraForm
    {
        private const string ConfirmInOutTypeIn = "入库确认日期：";
        private const string ConfirmInOutTypeOut = "出库确认日期：";
        private const string ConfirmInOutTypeInInvoice = "入库发票确认：";
        private readonly ConfirmInOutType _confirmInOutType = ConfirmInOutType.In;
        public FormConfirmInOut(ConfirmInOutType confirmInOutType)
        {
            InitializeComponent();
            this._confirmInOutType = confirmInOutType;
            this.dateEditBillDate.EditValue = DateTime.Now.Date;
            switch (this._confirmInOutType)
            {
                case ConfirmInOutType.In:
                    this.labelControlMsg.Text = ConfirmInOutTypeIn;
                    break;
                case ConfirmInOutType.Out:
                    this.labelControlMsg.Text = ConfirmInOutTypeOut;
                    break;
                case ConfirmInOutType.InInvoiceBill:
                    this.labelControlMsg.Text = ConfirmInOutTypeInInvoice;
                    break;
            }
        }

        public FormConfirmInOut(DateTime? dateTime, ConfirmInOutType confirmInOutType)
            :this(confirmInOutType)
        {
            if (dateTime != null)
            {
                this.dateEditBillDate.EditValue = dateTime;
            }
        }

        public DateTime? InOutDate { get; private set; }

        private void CmdOkClick(object sender, EventArgs e)
        {
            if( this.dateEditBillDate.EditValue == null)
            {
                XtraMessageBox.Show("请输入日期", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            var dateTime = (DateTime?)this.dateEditBillDate.EditValue;
            InOutDate = dateTime.Value.Date;
            this.DialogResult = System.Windows.Forms.DialogResult.OK;
        }

        private void CmdCancel_Click(object sender, EventArgs e)
        {
            this.DialogResult =System.Windows.Forms.DialogResult.Cancel;
        }
    }

    public  enum  ConfirmInOutType
    {
        In = 0,
        Out = 1,
        InInvoiceBill
    }
}